<!DOCTYPE html>
<html>
<head>
<title>Physics Diagram Fig. 2.84</title>
</head>
<body>
<canvas id="physicsCanvas" width="600" height="400"></canvas>
<script>
const canvas = document.getElementById('physicsCanvas');
const ctx = canvas.getContext('2d');

// White background
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);

// Set common drawing styles
ctx.strokeStyle = 'black';
ctx.fillStyle = 'black';
ctx.lineWidth = 3;

// --- Draw Components ---

// 1. Light Source (Box)
ctx.strokeRect(50, 125, 100, 100);

// 2. Light Beam
// Wavy part (zig-zag)
ctx.beginPath();
ctx.moveTo(150, 175);
ctx.lineTo(165, 167);
ctx.lineTo(180, 183);
ctx.lineTo(195, 167);
ctx.lineTo(210, 183);
ctx.lineTo(225, 167);
ctx.lineTo(240, 183);
ctx.lineTo(255, 167);
ctx.lineTo(270, 175); // Return to centerline
// Straight line part
ctx.lineTo(380, 175);
ctx.stroke();

// Arrowhead (filled)
const arrowX = 380;
const arrowY = 175;
ctx.beginPath();
ctx.moveTo(arrowX, arrowY);
ctx.lineTo(arrowX - 15, arrowY - 8);
ctx.lineTo(arrowX - 15, arrowY + 8);
ctx.closePath();
ctx.fill();

// 3. Target (Disc)
const targetCenterX = 420;
const targetCenterY = 175;
const radiusX = 30;
const radiusY = 60;
ctx.beginPath();
ctx.ellipse(targetCenterX, targetCenterY, radiusX, radiusY, 0, 0, 2 * Math.PI);
ctx.stroke();

// 4. Axle
ctx.beginPath();
ctx.moveTo(targetCenterX - radiusX, targetCenterY);
ctx.lineTo(targetCenterX + 110, targetCenterY);
ctx.stroke();

// --- Draw Labels ---

// Set font for main labels ("light", "target", "axle")
// A bold sans-serif font is used to replicate the simple, clear style of the original labels.
ctx.font = "bold 22px sans-serif";
ctx.textAlign = 'center';

// Label "light"
ctx.textBaseline = 'bottom';
ctx.fillText('light', 210, 160);

// Label "target"
ctx.textBaseline = 'top';
ctx.fillText('target', targetCenterX, targetCenterY + radiusY + 5);

// Label "axle"
ctx.textAlign = 'left';
ctx.textBaseline = 'middle';
ctx.fillText('axle', targetCenterX + 120, targetCenterY);

// Set font for the caption
// A bold serif font is used for the caption, as in the original image.
ctx.font = "bold 24px serif";
ctx.textAlign = 'center';
ctx.textBaseline = 'bottom';

// Caption "Fig. 2.84"
ctx.fillText('Fig. 2.84', canvas.width / 2, 380);

</script>
</body>
</html>